package com.shop.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class TimerIntercepter implements Interceptor{

	private static final long serialVersionUID = 1L;

	public void destroy() {}

	public void init() {}

	public String intercept(ActionInvocation invocation) throws Exception {
		//��ȡ��ǰִ�е�Action����ȫ�޶���
		Object obj = invocation.getAction();
		String className = obj.getClass().getName();
		System.out.println("ClassName:" + className);
		
		//
		ActionProxy proxy = invocation.getProxy();
		String actionName = proxy.getActionName();
		String methodName = proxy.getMethod();
		String namespace = proxy.getNamespace();
		
		System.out.println("actionName : " + actionName);
		System.out.println("methodName : " + methodName);
		System.out.println("namespace : " + namespace);
		
		
		long startTime = System.currentTimeMillis();
		
		String result = invocation.invoke();
		
		long timer = System.currentTimeMillis() - startTime;
		System.out.println(className + "��" + methodName + "������ʱ: " + timer + "ms");
		
		return result;
	}

}
